package com.yyb.learn.jbusine.service;

import com.alibaba.fastjson.JSONObject;
import com.yyb.common.bo.LoginUser;
import com.yyb.common.bo.RegisterUser;
import com.yyb.common.pojo.response.RespBody;
import com.yyb.learn.jbusine.dao.UserDao;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author yuyb40219
 * @Date 2021/9/28 15:43
 * Description:
 */
@Service
public class UserService {
    private static Logger LOGGER = LoggerFactory.getLogger(UserService.class);

    @Autowired
    private UserDao userDao;

    public JSONObject register(RegisterUser registerUser) {
        if (registerParamCheck(registerUser)) {
            return RespBody.failCodeMsg(10001, "参数有误");
        }

        String phone = registerUser.getPhone();
        if (StringUtils.isEmpty(phone)) {
            String password = registerUser.getPassword();

            userDao.insertUser(registerUser);
        }

        return null;
    }

    public JSONObject login(LoginUser loginUser) {


        return null;
    }

    private boolean registerParamCheck(RegisterUser registerUser) {
        return null == registerUser || StringUtils.isEmpty(registerUser.getAccount())
                || StringUtils.isEmpty(registerUser.getPassword());
    }

}